package com.ruoyi.web.controller.ring;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.ring.domain.RingExerciseInfo;
import com.ruoyi.ring.service.IRingExerciseInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 锻炼（128中锻炼类型）Controller
 * 
 * @author liuwp
 * @date 2025-09-25
 */
@RestController
@RequestMapping("/ring/ring_exercise_info")
public class RingExerciseInfoController extends BaseController
{
    @Autowired
    private IRingExerciseInfoService ringExerciseInfoService;

    /**
     * 查询锻炼（128中锻炼类型）列表
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_exercise_info:list')")
    @GetMapping("/list")
    public TableDataInfo list(RingExerciseInfo ringExerciseInfo)
    {
        startPage();
        List<RingExerciseInfo> list = ringExerciseInfoService.selectRingExerciseInfoList(ringExerciseInfo);
        return getDataTable(list);
    }

    /**
     * 导出锻炼（128中锻炼类型）列表
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_exercise_info:export')")
    @Log(title = "锻炼（128中锻炼类型）", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RingExerciseInfo ringExerciseInfo)
    {
        List<RingExerciseInfo> list = ringExerciseInfoService.selectRingExerciseInfoList(ringExerciseInfo);
        ExcelUtil<RingExerciseInfo> util = new ExcelUtil<RingExerciseInfo>(RingExerciseInfo.class);
        util.exportExcel(response, list, "锻炼（128中锻炼类型）数据");
    }

    /**
     * 获取锻炼（128中锻炼类型）详细信息
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_exercise_info:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(ringExerciseInfoService.selectRingExerciseInfoById(id));
    }

    /**
     * 新增锻炼（128中锻炼类型）
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_exercise_info:add')")
    @Log(title = "锻炼（128中锻炼类型）", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RingExerciseInfo ringExerciseInfo)
    {
        return toAjax(ringExerciseInfoService.insertRingExerciseInfo(ringExerciseInfo));
    }

    /**
     * 修改锻炼（128中锻炼类型）
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_exercise_info:edit')")
    @Log(title = "锻炼（128中锻炼类型）", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RingExerciseInfo ringExerciseInfo)
    {
        return toAjax(ringExerciseInfoService.updateRingExerciseInfo(ringExerciseInfo));
    }

    /**
     * 删除锻炼（128中锻炼类型）
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_exercise_info:remove')")
    @Log(title = "锻炼（128中锻炼类型）", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ringExerciseInfoService.deleteRingExerciseInfoByIds(ids));
    }
}
